const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const uglify = require('uglifyjs-webpack-plugin');
module.exports = {
    module: {
        rules: [
            {
                test: /\.jsx?$/,
                use: ['babel-loader'],
                exclude: /node_modules/, //排除 node_modules 目录
            },
        ],
    },
    output: {
        path: path.resolve(__dirname, 'dist'), //必须是绝对路径
        filename: 'app.min.js',
        publicPath: '/', //通常是CDN地址
    },
    plugins: [
        new CleanWebpackPlugin(), //每次打包前清空dist目录
        new uglify(), //压缩js
    ],
};
